package com.phb.puhuibao.common;
 
import com.itextpdf.text.pdf.CMYKColor;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.text.*;

import java.io.FileOutputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
 
import java.io.File;
import com.itextpdf.text.Document;
import com.itextpdf.text.Element;
import com.itextpdf.text.Font;
import com.itextpdf.text.Image;
import com.itextpdf.text.PageSize;
import com.itextpdf.text.Paragraph;
import com.itextpdf.text.Rectangle;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfPCell;
import com.itextpdf.text.pdf.PdfPTable;
 

public class HeaderAndFooterDemo {
	
	
	
	public static PdfPCell cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 cell.setPaddingBottom(5f);
		 cell.setCalculatedHeight(40f);
		 return cell;
	 }
	 
	public static PdfPCell cellleft(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 cell.setPaddingBottom(5f);
		 cell.setBorder(Rectangle.NO_BORDER);  
		 cell.setCalculatedHeight(40f);
		 return cell;
	 }
	 
	public static PdfPCell span2Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(2);// 设置合并的行数  
		 cell.setPaddingBottom(5f);
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 cell.setCalculatedHeight(40f);
		 return cell;
	 }
	public static PdfPCell span4Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(4);// 设置合并的行数  
		 cell.setPaddingBottom(5f);
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 cell.setCalculatedHeight(40f);
		 return cell;
	 }
	public static PdfPCell span3Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(3);// 设置合并的行数  
		 cell.setPaddingBottom(5f);
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 cell.setCalculatedHeight(40f);
		 return cell;
	 }
	
	public static PdfPCell span5Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(5);// 设置合并的行数  
		 cell.setCalculatedHeight(40f);
		 cell.setPaddingBottom(5f);
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 return cell;
	 }
	public static PdfPCell span10Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(10);// 设置合并的行数  
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 return cell;
	 }
	 
	public static PdfPCell span8Cell(String text, Font  font){
		 PdfPCell cell = new PdfPCell(new Paragraph(text, font));
		 cell.setColspan(8);// 设置合并的行数  
		 cell.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置内容水平居中显示  
		 cell.setVerticalAlignment(Element.ALIGN_MIDDLE);  // 设置垂直居中  
		 return cell;
	 }
	 
	private static Date getLastDate(Date date) {
	        Calendar cal = Calendar.getInstance();
	        cal.setTime(date);
	        cal.add(Calendar.MONTH, -1);
	        return cal.getTime();
	    }
	 
	 public static String getBatchString(){
 
			try {
				
			     Date date = new Date();
		         String batchName="";

				 SimpleDateFormat df=new SimpleDateFormat("yyyyMMdd");
				 SimpleDateFormat df1=new SimpleDateFormat("yyyyMM");
				 
				 String nowdate= df.format(date); 
				 String nowmonth= df1.format(date); 
			     String lastmonth =   df1.format(getLastDate(date)) ;
			     
			     String last25 = lastmonth+"25";
				 String this10 = nowmonth+"10";
				 String this25 = nowmonth+"25";
				 Date todaydate = df.parse(nowdate);
				 Date last25d =    df.parse(last25);
				 Date this10d =    df.parse(this10);
				 Date this25d =    df.parse(this25);
				 
				 
		         if(todaydate.after(this10d) && this25d.after(todaydate) || todaydate.equals(this25d)){//如果现在的时间是在这个月的10号和25号之间,包含15号
			        	batchName = nowmonth+"-02";
			     }else  if(todaydate.after(last25d) && this10d.after(todaydate) || todaydate.equals(this10d)){// 如果现在是本月10号（包含）和上月25号之间 
			        	batchName = nowmonth+"-01";
			     }	 
 
				 return batchName;
				 
			} catch (ParseException e) {
			 
				e.printStackTrace();
				 return "";
			}

			 

	 }
	 
	 
	 
    public static void main(String[] args){
        Document document = new Document(PageSize.A4,  36, 16, 124, 54);
        
        SimpleDateFormat sdf=new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
        Date current=new Date();  
             String targetname = sdf.format(current).substring(0,4) + "-";  
             targetname += sdf.format(current).substring(5,7) + "-";  
             targetname += sdf.format(current).substring(8,10) + "  ";  
             targetname += sdf.format(current).substring(11,13) + "-";                  
             targetname += sdf.format(current).substring(14,16) + "-";  
             targetname += sdf.format(current).substring(17,19) ;  
      
    	
        String file = "D:/forword/demo"+targetname+".pdf"; 
        String batchname = getBatchString();
        
        String stampfile ="D:/forword/stamp.png"; 
        String singniturefile ="D:/forword/signiture.png"; 
        
        try{
        	
        	File folder =new File("d:\\forword\\"+batchname);    
        	if  (!folder .exists()  && !folder .isDirectory())      {       
        	    folder .mkdir();    
        	}else {
        		System.out.println("已经产生了报表");
        	}   
        	file =   folder.getAbsolutePath()+"/"+targetname+".pdf";
            PdfWriter writer=PdfWriter.getInstance(document,
                    new FileOutputStream(file) );
            Rectangle rect = new Rectangle(36, 54, 559, 788);
            rect.setBorderColor(BaseColor.BLACK);
            writer.setBoxSize("art", rect);
            HeaderFooter header=new HeaderFooter();
            writer.setPageEvent(header);
            document.open();
            
            
            BaseFont bfChinese =BaseFont.createFont(  
                    "C:\\WINDOWS\\Fonts\\STFANGSO.TTF", BaseFont.IDENTITY_H,  
                    BaseFont.EMBEDDED); 
            Font FontChinese = new Font(bfChinese, 14, Font.NORMAL); // 其他所有文字字体       
            Font titleChinese = new Font(bfChinese, 14, Font.BOLD); // 粗体        
            Font bodyFontChineseunderline = new Font(bfChinese, 10, Font.UNDERLINE); // 模板抬头的字体     
            Font bodyFontChinese = new Font(bfChinese, 12, Font.NORMAL); // 币种和租金金额的小一号字体      
            Font bodysmall = new Font(bfChinese, 10, Font.NORMAL); // 币种和租金金额的小一号字体  
            Font moneyFontChinese = new Font(bfChinese, 8, Font.NORMAL); // 币种和租金金额的小一号字体      
            Font subBoldFontChinese = new Font(bfChinese, 8, Font.NORMAL); // 币种和租金金额的小一号字体  
             
            
            
//个人信息-------------------              
            String personal_post = "[117000]"; 
            Paragraph info_post = new Paragraph(personal_post,bodyFontChinese);  
            info_post.setLeading(-25f);//设置行间距//设置上面空白宽度  
            
            info_post.setAlignment(Element.ALIGN_LEFT);  
            info_post.setSpacingBefore(3);  
            document.add(info_post);  
            String personal_adress = "[北京市海淀区玉泉路甲2号院]"; 
            Paragraph info_adress = new Paragraph(personal_adress,bodyFontChinese);  
            info_adress.setAlignment(Element.ALIGN_LEFT);  
            info_adress.setSpacingAfter(20);  
      
            document.add(info_adress);  
            
            String personal_name = "[任欣 ] [女士] 亲启"; 
            Paragraph info_name = new Paragraph(personal_name,bodyFontChinese);  
            info_name.setIndentationLeft(40);
            info_name.setAlignment(Element.ALIGN_LEFT);  
            info_name.setSpacingBefore(3);  
            info_name.setExtraParagraphSpace(20);  
            document.add(info_name); 
            
            String personal_phone = "电话 [13910770671]"; 
            Paragraph info_phone = new Paragraph(personal_phone,bodyFontChinese);  
            info_phone.setIndentationLeft(40);
            info_phone.setAlignment(Element.ALIGN_LEFT);  
            info_phone.setSpacingBefore(3);  
            document.add(info_phone); 
            
            
//表1前的信息-------------------              
            Paragraph title = new Paragraph("资金出借情况报告", titleChinese);// 抬头  
       		title.setAlignment(Element.ALIGN_CENTER); // 居中设置  
       		title.setLeading(15f);//设置行间距//设置上面空白宽度  
       		document.add(title);  
       			
	       	 Paragraph hornored =  new Paragraph("尊敬的[任欣女士],您好：",bodyFontChinese);
	       	 info_name.setSpacingBefore(3); 
	         document.add(hornored); 
	         String statemen = "         感谢您选择金朗泰晟的咨询服务，参考金朗泰晟的推荐进行资金的出借增值，您目前出借的款项所产生的收益情况如下："; 
	         Paragraph info_statemen = new Paragraph(statemen,bodyFontChinese);  
	         info_statemen.setAlignment(Element.ALIGN_LEFT);  
	         info_statemen.setSpacingBefore(3);  
	         document.add(info_statemen); 
	         String moneystatemen = "货币单位：人民币（元）"; 
	         Paragraph money_statemen = new Paragraph(moneystatemen,bodyFontChinese);  
	         money_statemen.setAlignment(Element.ALIGN_RIGHT);  
	         money_statemen.setSpacingBefore(3);  
	         document.add(money_statemen); 
       		
//表1-------------------     
	         
	         PdfPTable table = new PdfPTable(4);// 创建该表格的列数，在本程序中设为5列  
	         table.setSpacingBefore(20f);//设置行间距//设置上面空白宽度  
	         int width[] = { 25, 25, 25, 25 };// 每列的单元格的宽度  
	         table.setWidths(width);// 设置每列所占比例  
	         table.setWidthPercentage(100f);
	         table.setHorizontalAlignment(Element.ALIGN_CENTER);
	         
	         table.addCell(span2Cell("报告周期",bodysmall));
	         table.addCell(span2Cell(" ",bodysmall));
	         table.addCell(span2Cell("账户级别",bodysmall));
	         table.addCell(span2Cell("聚财账户",bodysmall));
	         table.addCell(cell("报告日",bodysmall));
	         table.addCell(cell("[2016/01/23]",bodysmall));
	         table.addCell(cell("报告日资产总额",bodysmall));
	         table.addCell(cell("20000",bodysmall));
	         table.addCell(cell("出借编号",bodysmall));
	         table.addCell(cell("资金出借及回收方式",bodysmall));
	         table.addCell(cell("初始出借日期",bodysmall));
	         table.addCell(cell("初始出借金额",bodysmall));
	         table.addCell(cell("[8601020014]",bodysmall));
	         table.addCell(cell("[朗月盈]",bodysmall));
	         table.addCell(cell("[2015/12/23]",bodysmall));
	         table.addCell(cell("[20000]",bodysmall));
 
	         document.add(table);  
	         
	         
//表2---------------------------------------------       
	         String moneydetail = " 您目前的每笔出借款项实际回收情况及出借收益如下："; 
	         Paragraph money_detail = new Paragraph(moneydetail,bodyFontChinese);  
	         money_detail.setIndentationLeft(60);
	         money_detail.setAlignment(Element.ALIGN_LEFT);  
	         money_detail.setSpacingBefore(30);  
	         money_detail.setExtraParagraphSpace(20);  
	         document.add(money_detail); 
	         
	         table = new PdfPTable(10);
	         table.setSpacingBefore(20f);//设置行间距//设置上面空白宽度  
	         int width1[] = { 10, 10,10, 10,10, 10,10, 10,10, 10};// 每列的单元格的宽度  
	         table.setWidths(width1);// 设置每列所占比例  
	         table.setWidthPercentage(100); // 占页面宽度 90%，相当于html中width属性  
	         table.setHorizontalAlignment(Element.ALIGN_CENTER);// 设置该表格中的元素水平方向居中显示  
	         
	         table.addCell(cell("报告日",bodysmall));
	         table.addCell(cell("报告期内借款人应还款金额",bodysmall));
	         table.addCell(cell("报告期内借款人实际还款金额（或还款风险金代偿金额）",bodysmall));
	         table.addCell(cell("延迟支付应折减金额",bodysmall));
	         table.addCell(cell("账户管理费率",bodysmall));
	         table.addCell(cell("账户管理费",bodysmall));
	         table.addCell(cell("报告日内您选择受让的债权金额",bodysmall));
	         table.addCell(cell("报告日您选择回收的金额",bodysmall));
	         table.addCell(cell("报告日资产总额",bodysmall));
	         table.addCell(cell("报告期内实际收益",bodysmall));
	         
	         table.addCell(span10Cell("出借编号：[8601010124]",bodysmall));
	         
	         table.addCell(cell("[2016-03-03]",bodysmall));
	         table.addCell(cell("[758.33]",bodysmall));
	         table.addCell(cell("[758.33]",bodysmall));
	         table.addCell(cell("0.00",bodysmall));
	         table.addCell(cell("0%",bodysmall));
	         table.addCell(cell("0.00",bodysmall));
	         table.addCell(cell("0.00",bodysmall));
	         table.addCell(cell("[758.33]",bodysmall));
	         table.addCell(cell("[70,758.33]",bodysmall));
	         table.addCell(cell("[758.33]",bodysmall));
 
	         document.add(table);
       		
//表2前的文字---------------------------------------------------------------------------------------------------     
	            document.newPage();
	         
	            title = new Paragraph("既有债权列表", titleChinese);// 抬头  
	       		title.setAlignment(Element.ALIGN_CENTER); // 居中设置  
	       		title.setLeading(-25f);//设置行间距//设置上面空白宽度  
	       		document.add(title);  
	       		
		       	 moneydetail = "         通过金朗泰晟信用评估与筛选，推荐您通过受让他人既有的个人间借贷合同的方式，目前已经出借资金给如下借款人，详见《既有债权列表》 。"; 
		         money_detail = new Paragraph(moneydetail,bodyFontChinese);  
		         money_detail.setAlignment(Element.ALIGN_LEFT);  
		         money_detail.setSpacingBefore(20);  
		         money_detail.setSpacingAfter(20f);
		         document.add(money_detail); 
		         
		         
		         
//表3-----------------------------------------------------------------------------------------------------------
		         
		        table = new PdfPTable(12);
		        int width3[] = { 4,7,18, 10,9, 11,10, 10,8, 4,4, 5};// 每列的单元格的宽度  
		        table.setWidths(width3);
		        title.setLeading(15f);//设置行间距//设置上面空白宽度  
		        table.setWidthPercentage(100);
		        table.setHorizontalAlignment(Element.ALIGN_CENTER);
		        
		        table.addCell(span8Cell("债权基本信息",bodysmall));
		        table.addCell(span4Cell("借款人如约还款情况下债权收益信息",bodysmall));
		        
		        table.addCell(cell("序号",bodysmall));
		        table.addCell(cell("借款人姓名",bodysmall));
		        table.addCell(cell("借款人身份证号码",bodysmall));
		        table.addCell(cell("初始受让债权价值",bodysmall));
		        table.addCell(cell("[2016年03月03日]持有债权价值（元）",bodysmall));
		        table.addCell(cell("借款人借款情况",bodysmall));
		        table.addCell(cell("借款人借款用途",bodysmall));
		        table.addCell(cell("还款起始日期",bodysmall));
		        table.addCell(cell("本期还款金额",bodysmall));
		        table.addCell(cell("还款期限（月）",bodysmall));
		        table.addCell(cell("剩余还款月数",bodysmall));
		        table.addCell(cell("预计债权收益率（年）",bodysmall));
		        
		        
		        table.addCell(cell("[1]",bodysmall));
		        table.addCell(cell("林智明",bodysmall));
		        table.addCell(cell("352128197309303014",bodysmall));
		        table.addCell(cell("6250.00",bodysmall));
		        table.addCell(cell("5000.00",bodysmall));
		        table.addCell(cell("私营业主",bodysmall));
		        table.addCell(cell("扩大经营",bodysmall));
		        table.addCell(cell("2015/12/17",bodysmall));
		        table.addCell(cell("54.17",bodysmall));
		        table.addCell(cell("12",bodysmall));
		        table.addCell(cell("10",bodysmall));
		        table.addCell(cell("13%",bodysmall));
	 
		        
	 
		        table.addCell(span4Cell("合计",bodysmall));
		        table.addCell(cell("[70000.00]",bodysmall));
		        table.addCell(span3Cell("",bodysmall));
		        table.addCell(cell("[758.33]",bodysmall));
		        table.addCell(span3Cell("",bodysmall));
 
		        document.add(table);
	       			
 
//表3后的盖章部分--------------------------------------------------------------------------------------------- 	
		        
		        
		        moneydetail = "          感谢您选购金朗泰晟理财产品，金朗泰晟竭诚为您提供最优质高效的服务，如有疑问敬请联系您专属的理财经理或咨询"; 
		        money_detail = new Paragraph(moneydetail,bodyFontChinese);  
		        money_detail.setAlignment(Element.ALIGN_LEFT);  
		        money_detail.setSpacingBefore(30);  
		        money_detail.setExtraParagraphSpace(20);  
		        document.add(money_detail); 
		        moneydetail = "          服务热线：400-666-8618。"; 
		        money_detail = new Paragraph(moneydetail,bodyFontChinese);  
		        money_detail.setAlignment(Element.ALIGN_LEFT);  
		        money_detail.setExtraParagraphSpace(20);  
		        money_detail.setSpacingAfter(100); 
		        document.add(money_detail); 
 
       			float[] widthes = { 500f };// 设置表格的列宽和列数  
       			PdfPTable hiddenTable = new PdfPTable(widthes);// 建立一个pdf表格  
       			hiddenTable.setSpacingBefore(11f);  //设置表格上空间  
       			 
       			hiddenTable.setWidthPercentage(100);//设置表格宽度为%100  
       			hiddenTable.getDefaultCell().disableBorderSide(1);  
       			hiddenTable.getDefaultCell().disableBorderSide(2);  
       			hiddenTable.getDefaultCell().disableBorderSide(4);  
       			hiddenTable.getDefaultCell().disableBorderSide(8);  
       	 
       			Image upgif = Image.getInstance(stampfile);   
       			upgif.scalePercent(13f);
       			upgif.setAlignment(Element.ALIGN_LEFT);  
       			PdfPCell cell = new PdfPCell(new Paragraph("", bodyFontChinese));//描述  
       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
       			cell.addElement(upgif);  
       			cell.setPaddingTop(50f);             //设置内容靠上位置  
       		 
       			cell.setPaddingLeft(330f); 
       			cell.setBorder(Rectangle.NO_BORDER);//设置单元格无边框  
       			hiddenTable.addCell(cell);  
       			
       			cell = new PdfPCell(new Paragraph("金朗泰晟（北京）投资控股有限公司  ", bodyFontChinese));//金额  
       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
       			cell.setPaddingTop(-100f);  
       			cell.setPaddingLeft(300f); 
       			cell.setBorder(Rectangle.NO_BORDER);  
       			hiddenTable.addCell(cell);  
       			
       			cell = new PdfPCell(new Paragraph("盖章:                    ", bodyFontChinese));//金额  
       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
       			cell.setPaddingTop(-80f);  
       			cell.setPaddingLeft(300f); 
       			cell.setBorder(Rectangle.NO_BORDER);  
       			hiddenTable.addCell(cell);  
       			
       			cell = new PdfPCell(new Paragraph("日期：[2016.02.25]                   ", bodyFontChinese));//金额  
       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
       			cell.setPaddingTop(-60f);  
       			cell.setPaddingLeft(300f); 
       			cell.setBorder(Rectangle.NO_BORDER);  
       			hiddenTable.addCell(cell);  
       			
       			document.add(hiddenTable);  
            
//第3页 新用户有这一页 ......................................................................................... 
       	    document.newPage();
            title = new Paragraph("债权转让及受让协议", titleChinese);// 抬头  
             
       		title.setAlignment(Element.ALIGN_CENTER); // 居中设置  
       		title.setLeading(-25f);//设置行间距//设置上面空白宽度  
       		document.add(title);  
       		
	       	 moneydetail = "出借编号：[8601010124]"; 
	         money_detail = new Paragraph(moneydetail,bodysmall);  
	         money_detail.setAlignment(Element.ALIGN_RIGHT);  
	         money_detail.setSpacingBefore(10f);  
	         document.add(money_detail); 
	       	 moneydetail = "资金出借及回收方式：[金元宝]"; 
	         money_detail = new Paragraph(moneydetail,bodysmall);  
	         money_detail.setAlignment(Element.ALIGN_RIGHT);  
	         money_detail.setSpacingAfter(3f);
	         document.add(money_detail); 
	         
	         Phrase welcome =  new Phrase("尊敬的[任欣女士],您好:",bodysmall);
	         
 
	         document.add(welcome); 
	         statemen = "        通过金朗泰晟信用评估与筛选，推荐您[ 2016-02-03]通过受让他人既有的个人借贷合同的方式，出借资金给如下借款人，详见《债权列表》。"; 
	          info_statemen = new Paragraph(statemen,bodyFontChinese);  
	         info_statemen.setAlignment(Element.ALIGN_LEFT);  
	         info_statemen.setSpacingBefore(3);  
	         document.add(info_statemen); 
	         
	         moneystatemen = "债权列表"; 
	         money_statemen = new Paragraph(moneystatemen,bodyFontChinese);  
	         money_statemen.setAlignment(Element.ALIGN_CENTER);  
	           
	         document.add(money_statemen); 
	         
//第3页 隐藏列表 债权列表 ......................................................................................... 
	         
	         table = new PdfPTable(2);
	         table.setSpacingBefore(5f);//设置行间距//设置上面空白宽度  
	         
	         int width2[] = { 50,50};// 每列的单元格的宽度  
	         table.setWidths(width2);// 设置每列所占比例  
	         table.setWidthPercentage(80); // 占页面宽度 90%，相当于html中width属性  
	          
	         table.setSpacingBefore(5f);  //设置表格上空间  
    			 
    			 
	         table.getDefaultCell().disableBorderSide(1);  
	         table.getDefaultCell().disableBorderSide(2);  
	         table.getDefaultCell().disableBorderSide(4);  
	         table.getDefaultCell().disableBorderSide(8);  
    	 
	         table.addCell(cellleft("转让人（原债权人）：周烨",bodysmall));	 
	         table.addCell(cellleft("受让人（新债权人）：[任欣]",bodysmall));	
	         table.addCell(cellleft("身份证（护照）号码：110102198807051117",bodysmall));
	         table.addCell(cellleft("身份证（护照）号码：[370282198202194823]",bodysmall));
	         table.addCell(cellleft("转让债权明细：",bodysmall));
	         table.addCell(cellleft("货币单位：人民币（元）",bodysmall));
	         document.add(table); 
	         
	         
	         
//第3页表3  新用户有 ......................................................................................... 
	         
		        table = new PdfPTable(11);
		        int width4[] = {  4,7,18, 10,10, 11,10, 11,9, 5,5};// 每列的单元格的宽度  
		         table.setWidths(width4);// 设置每列所占比例  
		       
		        table.setWidthPercentage(100);
		        table.setHorizontalAlignment(Element.ALIGN_CENTER);
		        
		        table.addCell(span8Cell("债权基本信息",bodysmall));
		        table.addCell(span4Cell("借款人如约还款情况下债权收益信息",bodysmall));
		        
		        table.addCell(cell("序号",bodysmall));
		        table.addCell(cell("借款人姓名",bodysmall));
		        table.addCell(cell("借款人身份证号码",bodysmall));
		        table.addCell(cell("[2016年03月03日]持有债权价值（元）",bodysmall));
		        table.addCell(cell("借款人借款情况",bodysmall));
		        table.addCell(cell("借款人借款用途",bodysmall));
		        table.addCell(cell("还款起始日期",bodysmall));
		        table.addCell(cell("本期还款金额",bodysmall));
		        table.addCell(cell("还款期限（月）",bodysmall));
		        table.addCell(cell("剩余还款月数",bodysmall));
		        table.addCell(cell("预计债权收益率（年）",bodysmall));
		        
		        
		        table.addCell(cell("[1]",bodysmall));
		        table.addCell(cell("林智明",bodysmall));
		        table.addCell(cell("352128197309303014",bodysmall));
		        table.addCell(cell("5000.00",bodysmall));
		        table.addCell(cell("私营业主",bodysmall));
		        table.addCell(cell("扩大经营",bodysmall));
		        table.addCell(cell("2015/12/17",bodysmall));
		        table.addCell(cell("54.17",bodysmall));
		        table.addCell(cell("12",bodysmall));
		        table.addCell(cell("10",bodysmall));
		        table.addCell(cell("13%",bodysmall));
	 
		        
	 
		        table.addCell(span3Cell("合计",bodysmall));
		        table.addCell(cell("[70000.00]",bodysmall));
		        table.addCell(span3Cell("",bodysmall));
		        table.addCell(cell("[758.33]",bodysmall));
		        table.addCell(span3Cell("",bodysmall));

		        document.add(table); 
		        
		        
// 债权列表 后的文字  ..................................................		
		        
		         moneystatemen = "转让人声明"; 
		         money_statemen = new Paragraph(moneystatemen,bodyFontChinese);  
		         money_statemen.setAlignment(Element.ALIGN_CENTER);  
		         money_statemen.setSpacingBefore(3);  
		         document.add(money_statemen); 
		         
		         statemen = "        本人自愿将上述债权转让给受让人，如果受让人对上述债权转让没有异议须于[2016-02-08]前将上述对价共计人民币（大写）[柒万元整]（人民币小写￥[70,000.00]）支付到本人指定账户。"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         document.add(info_statemen); 
		         statemen = "         自款项到账次日起，上述债权转让即生效，债权转让生效后，署有本人签章的本文件即代表受让人对上述债权的所有权。本人特此签章声明。转让人：见证人：金朗泰晟（北京）投资控股有限公司"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         
		         document.add(info_statemen); 
		         
// 债权列表 后的签字  ..................................................		         
		            float[] widthes1 = { 50f,50f };// 设置表格的列宽和列数  
	       			 hiddenTable = new PdfPTable(widthes1);// 建立一个pdf表格  
	       		 
	       			 
	       			hiddenTable.setWidthPercentage(70);//设置表格宽度为%100  
	       			hiddenTable.getDefaultCell().disableBorderSide(1);  
	       			hiddenTable.getDefaultCell().disableBorderSide(2);  
	       			hiddenTable.getDefaultCell().disableBorderSide(4);  
	       			hiddenTable.getDefaultCell().disableBorderSide(8);  
	       	 
	       			upgif = Image.getInstance(singniturefile);   
	       			upgif.scalePercent(40f);
	       			upgif.setAlignment(Element.ALIGN_LEFT);  
	       			
	       		    cell = new PdfPCell(new Paragraph("", bodyFontChinese));//描述  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.addElement(upgif);  
	       			cell.setPaddingLeft(50f); 
	       			cell.setBorder(Rectangle.NO_BORDER);//设置单元格无边框  
	       			hiddenTable.addCell(cell);  
	       			
	       			upgif = Image.getInstance(stampfile);   
	       			upgif.scalePercent(9f);
	       			upgif.setAlignment(Element.ALIGN_LEFT);  
	       			
	       		    cell = new PdfPCell(new Paragraph("", bodyFontChinese));//描述  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.addElement(upgif);  
	       			cell.setPaddingLeft(50f); 
	       			cell.setBorder(Rectangle.NO_BORDER);//设置单元格无边框  
	       			hiddenTable.addCell(cell);  
 
	       			cell = new PdfPCell(new Paragraph("签字:", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setPaddingTop(-70f);  
	       			cell.setPaddingLeft(20f); 
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			hiddenTable.addCell(cell);  
	       			
	       			cell = new PdfPCell(new Paragraph("盖章:", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setPaddingTop(-70f);  
	       			cell.setPaddingLeft(20f); 
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			hiddenTable.addCell(cell);  
	       			
	       			cell = new PdfPCell(new Paragraph("日期：[2016.02.25]                   ", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setPaddingTop(-50f);  
	       			cell.setPaddingLeft(20f); 
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			hiddenTable.addCell(cell);  
	       			
	       			cell = new PdfPCell(new Paragraph("日期：[2016.02.25]                   ", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setPaddingTop(-50f);  
	       			cell.setPaddingLeft(20f); 
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			hiddenTable.addCell(cell);  
	       			
	       			document.add(hiddenTable); 
// 画直线------------------------------------------------------------------------------------------	       			
	       		 PdfContentByte canvas = writer.getDirectContent();
	             CMYKColor magentaColor = new CMYKColor(1.f, 1.f, 1.f, 1.f);
	             canvas.setColorStroke(magentaColor);
	             canvas.moveTo(20, 260);
	             canvas.lineTo(575, 260);
	             canvas.closePathStroke();
	             
	             statemen = "        金朗泰晟提示："; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         document.add(info_statemen); 
		         
		         statemen = "              如果受让人对上述债权全部或部分不认可，请填写本回执，标明所拒绝的债权序号，在[2016-02-08]前将回执交给金朗泰晟并自己保留一份取得金朗泰晟协调进行其他债权的推荐。"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         document.add(info_statemen);
	             
		         statemen = "债权转让拒绝回执"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_CENTER);  
		         document.add(info_statemen); 
		         
		         statemen = "             本人拒绝转让人周烨上述欲转让给本人的第  号（依次填写序号）债权，本人将不予支付该债权的对价；对于其他未拒绝的债权，将按时支付对价。请金朗泰晟知悉并见证。"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         document.add(info_statemen); 
		         
		         statemen = "             本人特此签章声明。受让人：见证人：金朗泰晟（北京）投资控股有限公司"; 
		          info_statemen = new Paragraph(statemen,bodyFontChinese);  
		         info_statemen.setAlignment(Element.ALIGN_LEFT);  
		         document.add(info_statemen); 
		         
		         
		            table = new PdfPTable(2);
			        title.setLeading(10f);//设置行间距//设置上面空白宽度  
			        table.setSpacingBefore(5f);  //设置表格上空间  
			        table.setWidthPercentage(50f);
			        table.setHorizontalAlignment(Element.ALIGN_CENTER);
			        
			        cell = new PdfPCell(new Paragraph("签章：", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			table.addCell(cell);  
	       			cell = new PdfPCell(new Paragraph("签章：", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			table.addCell(cell);  
	       			cell = new PdfPCell(new Paragraph("日期：", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			table.addCell(cell);  
	       			cell = new PdfPCell(new Paragraph("日期：", bodyFontChinese));//金额  
	       			cell.setHorizontalAlignment(Element.ALIGN_LEFT);// 设置内容水平居中显示  
	       			cell.setBorder(Rectangle.NO_BORDER);  
	       			table.addCell(cell);  
			        
		 

			        document.add(table); 
		         
		         
		        

		         
		         
		         
 
         

            document.close();
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}